package logic

import (
	"context"
	"renting-demo/api/internal/svc"
	"renting-demo/api/internal/types"
	"renting-demo/goods_srv/goodsclient"
	"strconv"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelProductLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDelProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelProductLogic {
	return &DelProductLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DelProductLogic) DelProduct(req *types.DelProductReq) (resp *types.Data, err error) {
	// todo: add your logic here and delete this line
	res, _ := l.svcCtx.GoodsServer.DelProduct(context.Background(), &goodsclient.DelProductReq{
		GoodsID: int64(req.Goodsid),
	})
	return &types.Data{
		Code:    0,
		Message: "删除成功",
		Data:    map[string]string{"status": strconv.FormatInt(res.Status, 10)},
	}, nil
}
